package net.dodoman;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Reader {
	public static void main(String[] args) throws IOException {
		Reader reader = new Reader();
		reader.inserIntoDb();
	}

	private void inserIntoDb() throws IOException {
		List<String> wordList = getWordList();
		String wholeWord = "", keyWordInc = "";
		for (String every : wordList) {
			wholeWord = every.substring(0, 4);
			keyWordInc = every.substring(5, 6);
		}
		System.out.println(wholeWord);
		System.out.println(keyWordInc);
	}

	// 读取文件到字符串
	private String readFile() throws IOException {
		File read = new File("E:\\Work\\JavaPro\\resources\\Temp.txt");
		BufferedReader br = new BufferedReader(new FileReader(read));
		String temp = null;
		StringBuffer sb = new StringBuffer();
		temp = br.readLine();
		sb.append(temp);
		while (temp != null) {
			temp = br.readLine();
			if (temp != null)
				sb.append(temp);
		}
		br.close();
		temp = sb.toString();
		return temp;
	}

	// 获取需要的词语列表
	private List<String> getWordList() throws IOException {
		Reader reader = new Reader();
		// String text = reader.readFile();
		String[] text = reader.readFile().split("）");
		List<String> wordList = new ArrayList<String>();
		for (String every : text) {
			wordList.add(every);
			System.out.println(every);
		}
		return wordList;
	}
}
